package com.gin.kotlin.vegetables_kot.base

/**
 * 持有Handler的对象
 */
interface HandlerHolder {
    /**
     * handler
     */
    var handler: MyHandler?

    fun toast(message: String) = this.handler?.toast(message)

    fun toastLong(message: String) = this.handler?.toastLong(message)

    /**
     * 使用ui进程执行
     * @param runnable Runnable
     * @return Boolean?
     */
    fun ui(runnable: Runnable) = this.handler?.post(runnable)

    /**
     * 使用ui进程延迟执行
     * @param runnable Runnable?
     * @param delayMillis Long
     * @return Boolean?
     */
    fun uiDelayed(delayMillis: Long, runnable: Runnable?) = this.handler?.postDelayed(runnable!!, delayMillis)
}